package com.xm.xmapp.customview;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.xm.xmapp.R;

public class CustomLayoutText extends RelativeLayout {

	private TextView text1, text2;

	public CustomLayoutText(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
		View view = LayoutInflater.from(context).inflate(
				R.layout.view_customlayouttext, this, true);

		text1 = (TextView) view.findViewById(R.id.text1);

		text2 = (TextView) view.findViewById(R.id.text2);
		TypedArray a = context.obtainStyledAttributes(attrs,
				R.styleable.customLayout);
		String str1 = (String) a.getText(R.styleable.customLayout_text1);
		if (str1 != null)
			text1.setText(str1);

		String str2 = (String) a.getText(R.styleable.customLayout_text2);
		if (str2 != null)
			text2.setText(str2);
		int textColor2 = a.getColor(R.styleable.customLayout_text2Color,
				0XFFFFFFFF);
		if (textColor2 != 0XFFFFFFFF) {
			text2.setTextColor(textColor2);
		}
		a.recycle();
	}

	public void setText2(String str2) {
		if (text2 != null && str2 != null)
			text2.setText(str2);
	}
	
	public void setText2Color(String color)
	{
		try {
			
			text2.setTextColor(Color.parseColor(color));
			
		} catch (Exception e) {
			// TODO: handle exception
		}
	}
	
	public TextView getTextView2()
	{
		return text2;
	}
}
